<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
	<head>
		<title>请假详情</title>
	    <%@include file="/common/commonCSS.jsp" %>
	    <%@include file="/common/commonJS.jsp" %>
		<%@ include file="/WEB-INF/jsp/include/taglib.jsp"%>
	</head>
	<body >
		<div class="main-container" id="main-container">
			<form class="form-horizontal  bv-form" id="incidentForm">
				<div style="display: none">
					<input id="id" name="id"  value="${incidentInfo.id}"/>
				</div>
				<div class="row">
					<div class="form-group col-xs-12 ">
						<label class="col-xs-3 control-label no-padding-right"><i class="red"> * </i>工单编号:</label>
						<div class="col-xs-9">
							<span class="col-xs-11 block input-icon input-icon-right">
								<input id="incNo" name="incNo" type="text" class="form-control" value="${incidentInfo.incNo}" readonly/>
							</span>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="form-group col-xs-12 ">
						<label class="col-xs-3 control-label no-padding-right"><i class="red"> * </i>标题:</label>
						<div class="col-xs-9">
							<span class="col-xs-11 block input-icon input-icon-right">
								<input id="incTopic" name="incTopic" datatype="*1-64" nullmsg="标题不能为空!" type="text" class="form-control" value="${incidentInfo.incTopic}"/>
							</span>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="form-group col-xs-12">
						<label class="col-xs-3 control-label no-padding-right"><i class="red"> * </i>描述:</label>
						<div class="col-xs-9">
							<span class="col-xs-11 block input-icon input-icon-right">
								<textarea id="incContent" name="incContent" datatype="*1-500"  class="form-control" rows="3">${incidentInfo.incContent}</textarea>
							</span>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="form-group col-xs-12">
						<label class="col-xs-3 control-label no-padding-right"><i class="red"> * </i>业务系统:</label>
						<div class="col-xs-9">
							<div class="col-xs-9">
								<input  id="operationName" datatype="*" nullmsg="业务系统不能为空!" onclick="selectBus()" placeholder="请选择业务系统" name="operationName" readonly type="text" class="form-control" value="${incidentInfo.operationName}"/>
								<input  style="display:none" id="operation" datatype="*" nullmsg="业务不能为空!" onclick="selectBus()" placeholder="请选择业务" name="operation" readonly type="text" class="form-control" value="${incidentInfo.operation}"/>
							</div>
							<div class="col-xs-3">
								<button type="button" class="layui-btn layui-btn-small" onclick="selectBus()">选择 <i class="layui-icon">&#xe61a;</i></button>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="form-group col-xs-12">
						<label class="col-xs-3 control-label no-padding-right"><i class="red"> * </i> 事件来源:</label>
						<div class="col-xs-9">
							<span class="col-xs-11 block input-icon input-icon-right">
								<tag:select nameKey="incOrigin" name="incOrigin" clazz="form-control" otherAttr="datatype=\"*\" " isAddDefaltOption="true" defaltOptionValue="--请选择--" initSelectedKey="${incidentInfo.incOrigin}"/>

							</span>
						</div>
					</div>
				</div>

				<c:forEach items="${fieldList}" var="firld" varStatus="i">
					<div class="row">
						<div class="form-group col-xs-12 ">
							<label class="col-xs-3 control-label no-padding-right"><c:if test="${firld.flagRequired==true}" ><i class="red"> * </i></c:if>${firld.field}:</label>
							<div class="col-xs-9">
							<span class="col-xs-11 block input-icon input-icon-right">
								<input  name="valueDictionarys[${i.index}].fieldId" type="hidden" value="${firld.id}"/>
								 <c:if test="${firld.fieldType == '1'}">
									<input  name="valueDictionarys[${i.index}].fieldValue"  <c:if test="${firld.flagRequired==true}" >datatype="*1-64"</c:if>$type="text" class="form-control" value="<c:forEach items="${incidentInfo.valueDictionarys}" var="valueDictionary"><c:if test="${firld.id == valueDictionary.fieldId}">${valueDictionary.fieldValue}</c:if></c:forEach>"/>
								 </c:if>
								 <c:if test="${firld.fieldType == '2'}">
									 <textarea  name="valueDictionarys[${i.index}].fieldValue"  <c:if test="${firld.flagRequired==true}" > datatype="*1-500" </c:if>class="form-control" rows="3"><c:forEach items="${incidentInfo.valueDictionarys}" var="valueDictionary"><c:if test="${firld.id == valueDictionary.fieldId}">${valueDictionary.fieldValue}</c:if></c:forEach></textarea>

								 </c:if>
							</span>
							</div>
						</div>
					</div>

				</c:forEach>
				<div class="row" style="margin-left: 40%;padding-bottom: 28px;margin-top: 25px;">
					<button class="layui-btn" type="button" id="submitBtn">保 存</button>
					<a class="layui-btn layui-btn-normal" href="${webRoot}/incident/incidentinfo/list">返 回</a>
				</div>
			</form>
		</div>
	</body>
	<div style="display: none;padding:10px;" id="operationTree">
		<span>业务树:</span>
		<ul name="operationTree" class="ztree"></ul>
	</div>
	<script>
        var setting = {
            view: {dblClickExpand: false}
            ,data: {key: {name:"name"},simpleData: {enable: true,idKey: "id",pIdKey: "parentId"}}
            ,callback: {}
        };
        var ztree;
        $(function(){
            var data='${operationTree}';
            ztree=$.fn.zTree.init($("ul[name='operationTree']"), setting, eval(''+data+''));//ztree树加载
        });

        //选择业务弹框
        function selectBus() {
            var modelId='${model.operationList.id}';
            if(modelId !=''){
                alertMsg("保存后,就不能修改了");
            }else {
                layer.open({
                    type: 1,
                    offset: '0px',
                    skin: 'layui-layer-molv',
                    title: "选择业务系统",
                    area: ['250px', '350px'],
                    shade: 0,
                    shadeClose: false,
                    content: $("#operationTree"),
                    btn: ['确定', '取消'],
                    btn1: function (index) {
                        var node = ztree.getSelectedNodes();
                        if(node[0].type == '2'){
                            alertMsg("只能选择业务类，不能选择分组!");
                            return;
                        }
                        //选择上级菜单
                        $("#operation").val(node[0].id);
                        $("#operationName").val(node[0].name);
                        layer.close(index);
                    }
                });
            }
        }
		//提交
		$("#submitBtn").click(function () {
            checkFormValid($("#incidentForm"),function () {
			var url ="${webRoot}/incident/incidentinfo/edit";
			$.post(url,$("#incidentForm").serialize(),function (result) {
				if(result.code == '0'){
					if($("#id").val() == ''){
                        alert(result,function () {
                            location.href='${webRoot}/incident/incidentinfo/list';
                        },function () {
                            $("#submitBtn").reset();
                        });
					}else {
                        //更新成功，返回List页面
                        toast(result.msg);
                        location.href='${webRoot}/incident/incidentinfo/list';
					}
				}else {
					alertMsg(result.msg);
				}

			});
		})
		});
	</script>
</html>